package
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	
	import com.kairos.engine.RTBeacon;
	import com.kairos.motion.MovieClipRT;
	import com.kairos.utils.Monitor;
	import com.kairos.utils.MonitorFieldsList;	
	
	[SWF(width="600",height="180",frameRate="60",backgroundColor="#000000")]	
	public class AnimationFPRunner extends Sprite
	{
		private var _oMonitor : Monitor;
		private var _oButton : Sprite;
		
		private var _oAnimation1 : MovieClip;
		private var _oAnimation2 : MovieClip;
		
		private var _oAnimController1 : MovieClipRT;
		
		[Embed(source="../lib/example-lib.swf", symbol="Button")]
			private var SimpleButton : Class;
			
		[Embed(source="../lib/example-lib.swf", symbol="Animation")]
			private var Animation : Class;
		
		public function AnimationFPRunner ()
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			RTBeacon.getInstance().setMaxStepSize( 100 );
			RTBeacon.getInstance().setSmoothness( 10 );

			_oButton = new SimpleButton () as Sprite;
			_oButton.width = 598;
			_oButton.height = 178;
			_oMonitor = new Monitor ( 80, 80 );
			
			_oAnimation1 = new Animation() as MovieClip;
			_oAnimation2 = new Animation() as MovieClip;
			
			_oAnimation1.x = 100;
			_oAnimation2.x = 360;
			_oAnimation2.stop();
			
			_oAnimController1 = new MovieClipRT( _oAnimation1, 24 );

			_oButton.alpha = .5;
			
			_oMonitor.addField( MonitorFieldsList.FPS );

			addChild( _oAnimation1 );
			addChild( _oAnimation2 );
			addChild( _oButton );
			addChild( _oMonitor );
			
			addEventListener( MouseEvent.MOUSE_OVER, start );
			addEventListener( MouseEvent.MOUSE_OUT, stop );
		}
		
		public function start( e : Event = null ) : void
		{
			Mouse.hide();
			_oMonitor.start();
			_oButton.alpha = 0;
			
			_oAnimController1.start();
			_oAnimation2.play();		
		}
		
		public function stop( e : Event = null ) : void
		{
			Mouse.show();
			_oMonitor.stop();
			_oButton.alpha = .5;
			
			_oAnimController1.stop();
			_oAnimation2.stop();
		}
	}
}